Using POUND SIGN as a string in PYTHON?

前端 未结 3 1525
情深已故
情深已故 2021-01-27 04:16

I want to have a string containing 4 pound signs..how can I accomplish this in Python without commenting the string out due to the pound signs?

相关标签:
3条回答
  • 2021-01-27 04:39

    What about:

    x = '####'
    

    If between quotes, it will not be a comment!

    0 讨论(0)
  • 2021-01-27 04:39

    As said before, single quotes do the job for string literals. You might also want to have a look at Python documentation

    0 讨论(0)
  • 2021-01-27 04:55

    If some IDE interprets '####' as a half-baked string plus a comment, change the IDE!

    0 讨论(0)
提交回复
热议问题