Home  >  Q&A  >  body text

A strange question about PYTHON strings, I can’t figure it out

Using python to make restful api server, on home computer and work computer, now I encounter some strange problems

Use postman to send a post request. The value of the key received by the home computer will be found to be u'Chinese' when debugging is interrupted. However, if it is a computer at work, it will be displayed as 'Chinese' when debugging is interrupted. Yes, the difference is whether there is a u in front or not. This difference between the two computers almost makes me depressed,

I am using python 3.61 64bit, and the environment is synchronized using requirements.txt. The installed libraries should be consistent. Why does this happen? how to solve this problem? The difference between the two computers is killing me

The code should be the same, use github to synchronize the warehouse of two computers

Is it related to the settings of pycharm I use?

淡淡烟草味淡淡烟草味2712 days ago575

reply all(2)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-18 10:52:20

    Py3’s strings are unicode by default, regardless of whether there is a u prefix or not

    reply
    0
  • 高洛峰

    高洛峰2017-05-18 10:52:20

    Are the Python versions of the two environments inconsistent? Those with u are generally generated by py2. Just change the Python version to py3

    reply
    0
  • Cancelreply