1. # Join
    2. print("and".join(["Jack", "Tom"]))
    3. > Jack and Tom
    4. print("and".join(["Jack", "Tom", "Jessica"]))
    5. > Jack and Tom and Jessica
    6. # Format
    7. print("你和{}".Format("我"))
    8. > 你和我
    9. print("{}你和".Format("我"))
    10. >我你和

    当然还有 %s ,但更推荐使用format,任何在设计到字符替换的都可使用到

    1. with open("{}_name.txt".format(api), "a+") as f:
    2. f.write("{}, {}\n".format(uid["user-id"], uid.string))
    3. f.close()
    4. string_to_sign = '{}\n{}'.format(timestamp, app_secret)
    5. msg = "You get a new version. {}\nThe download link : {}\n".format(get_version, get_url)