All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
If your interaction with these professors was in a forbidden situation, it is not permissible for you to seek knowledge from them, the aim here does not justify the mean. The forbidden mixing is what involves being alone with a foreigner (non-Mahram man) or being soft in speech [to men], and the like.
The Encyclopedia of Fiqh (jurisprudence) reads: “The ruling on the mixing of men with women differs according to whether or not it agrees with the rulings of Sharee'ah. Mixing is prohibited in these cases:
A. Being alone with a non-mahram woman and looking lustfully at her.
B. Women not wearing Hijab and not being modestly dressed.
C. “Playful amusement and body touching (between men and women), such as the mixing at weddings, birthdays, and holidays. Thus, the mixing that includes such matters is forbidden, because it violates the rulings of Sharee'ah.”
Likewise, if you do not feel safe in yourself from being tempted by men, it is not permissible for you to seek knowledge from them, even if mixing with them is not in a way that is contrary to the rulings of Sharee'ah. You can seek knowledge while you are at home by listening to explanations of books, lectures, and the like as seeking knowledge does not depend on going out and mixing with men.
Allah knows best.