如何在python中用两个不同的行写一个链接?

时间:2017-11-29 14:42:48

标签: python web

我有以下代码,我想在两个不同的行中写链接,但我不能使用三重引号(“”“),我想要一个有效的方法来做到这一点:

toy_story数据

toy_story = media.Movie("Toy Story",
                    "A story of a boy an his toy that come to life",
                    "https://upload.wikimedia.org/wikipedia/en/1/13/Toy_Story.jpg",
                    "https://www.youtube.com/watch?v=KYz2wyBy3kc")

头像数据

avatar = media.Movie("Avatar",
                 "A marine on an alien planet",
                 "https://upload.wikimedia.org/wikipedia/en/b/b0/Avatar-Teaser-Poster.jpg",
                 "https://www.youtube.com/watch?v=5PSNL1qE6VY")

1 个答案:

答案 0 :(得分:0)

我可能会这样做:

avatar = media.Movie(
    "Avatar",
    "A marine on an alien planet",
    (
        "https://upload.wikimedia.org"
        "/wikipedia/en/b/b0/Avatar-Teaser-Poster.jpg"
    ),
    "https://www.youtube.com/watch?v=5PSNL1qE6VY",
)

它使用python将("foo" "bar" "baz")视为等效且等于"foobarbaz"的事实。