Linux 如何在gist api github中传递多行信息

Linux 如何在gist api github中传递多行信息,linux,python-3.x,github,github-api,gist,Linux,Python 3.x,Github,Github Api,Gist,在第一个代码中,self.info包含单个长度的字符串,因此它可以工作;在第二个代码中,当我试图发送更长的字符串时,它失败了 import requests,json,datetime,time import global_vars as gv class Create_gist: "Class for gist creation" def __init__(self,url): self.url=url

在第一个代码中,self.info包含单个长度的字符串,因此它可以工作;在第二个代码中,当我试图发送更长的字符串时,它失败了

    import requests,json,datetime,time
    import global_vars as gv
    class Create_gist:
        "Class for gist creation"
        def __init__(self,url):
            self.url=url
            self.headers=gv.headers
        def create(self):
            self.des=input("Enter the description for gist")
            self.public=input("Make this gist public (y/n)")
            if self.public=='y' or self.public=='Y':
                self.public='true'
            else:
                self.public='false'
            self.file_name=input("Enter the file name with extension ")
            with open(self.file_name,'r') as myfile:
                self.fdata=myfile.read().replace("\n", " ")
            print(self.fdata)
            self.info="hello vishal here"
            self.date=datetime.date.today()
            self.c_time=time.strftime("%H:%M:%S")
            self.send_dict="""{"description":"%s",
                    "public":"%s",
                    "files":{
                        "%s":{
                            "content":"%s"
                            }
                        }
                    }"""
            self.send_dict=self.send_dict%(self.des,self.public,self.name,self.info)
            re=requests.post('https://api.github.com/gists',headers=self.headers,data=self.send_dict)
            print(re.status_code)
但是当self.info包含超过一个长度的字符串时,它就不起作用了

    import requests,json,datetime,time
    import global_vars as gv
    class Create_gist:
        "Class for gist creation"
        def __init__(self,url):
            self.url=url
            self.headers=gv.headers
        def create(self):
            self.des=input("Enter the description for gist")
            self.public=input("Make this gist public (y/n)")
            if self.public=='y' or self.public=='Y':
                self.public='true'
            else:
                self.public='false'
            self.file_name=input("Enter the file name with extension ")
            with open(self.file_name,'r') as myfile:
                self.fdata=myfile.read().replace("\n", " ")
            print(self.fdata)
            self.info="""hello 
            vishal here"""
            self.date=datetime.date.today()
            self.c_time=time.strftime("%H:%M:%S")
            self.send_dict="""{"description":"%s",
                    "public":"%s",
                    "files":{
                        "%s":{
                            "content":"%s"
                            }
                        }
                    }"""
            self.send_dict=self.send_dict%(self.des,self.public,self.name,self.info)
            re=requests.post('https://api.github.com/gists',headers=self.headers,data=self.send_dict)
            print(re.status_code)
我错过什么了吗?还是我用错了