Print a list that contains Chinese characters in Python

后端 未结 2 923
悲哀的现实
悲哀的现实 2020-12-19 13:13

My code looks like :

# -*- coding: utf-8 -*-

print [\"asdf\", \"中文\"]
print [\"中文\"]
print \"中文\"

The output in the Eclipse console is ver

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-19 14:01

    The first two are using the __repr__ of the strings, the last one is using the __str__ method

    You could use

    print ", ".join(["asdf", "中文"])
    

提交回复
热议问题