小编Fis*_*shy的帖子

为什么有些方法使用点符号而其他方法没有?

所以,我刚开始学习Python(使用Codecademy),我有点困惑.

为什么有一些方法需要参数,而其他方法使用点符号?

len()采用了一个arugment,但是不能使用点符号:

>>> len("Help")
4
>>>"help".len()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'len'
Run Code Online (Sandbox Code Playgroud)

同样地:

>>>"help".upper()
'HELP'
>>>upper("help")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'upper' is not defined
Run Code Online (Sandbox Code Playgroud)

python methods syntax

16
推荐指数
1
解决办法
1万
查看次数

通过python发布问题

我有点麻烦.我正在尝试发送一个POST并试图按照文档,但我似乎无法正确.

在github上:https://github.com/trtmn/Python

拉请求欢迎!

# Getting documentation from :
#https://docs.python.org/2/howto/urllib2.html 
import urllib
import urllib2

url = 'https://hooks.slack.com/services/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'
values = {"username": "webhookbot", "text": "This is posted to #general and comes from a bot named webhookbot.", "icon_emoji": ":ghost:"}

data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
Run Code Online (Sandbox Code Playgroud)

python post cgi http

3
推荐指数
1
解决办法
1113
查看次数

如何在python中格式化电话号码

所以,我对电话号码格式化程序的实现非常糟糕。它应该将电话号码的实例值格式化并以 xxx.xxx.xxxx 的格式返回(现在它应该只是一个美国电话号码)

代码可以在这个要点上找到:https : //gist.github.com/trtmn/a5a51c3da55ae0b32ac8

    phone = models.CharField(max_length=20, blank=True)
def formatphone(self): #Dear Future Self - I'm so very sorry.
    formattedphone = ""
    for x in self.phone:
        if x == "1":
            formattedphone = formattedphone + x
        if x == "2":
            formattedphone = formattedphone + x
        if x == "3":
            formattedphone = formattedphone + x
        if x == "4":
            formattedphone = formattedphone + x
        if x == "5":
            formattedphone = formattedphone + x
        if x == "6":
            formattedphone = formattedphone …
Run Code Online (Sandbox Code Playgroud)

python string-formatting phone-number

1
推荐指数
1
解决办法
4524
查看次数

为什么CSS会有8像素边框?

我有一个想增加的8像素边框,但是我找不到它的来源。另外,如果我使用边距,它会不成比例地增加边框。

多出8个像素? 为什么?

CSS和整个项目在这里可用: CSS Resume Project

    @font-face {
    font-family: "Open Sans";
    src: url(Open_Sans/OpenSans-Regular.ttf);
}
.global {
    /*border: solid 10px lightgray;*/
    border-radius: 25px;
    font-family: 'Open Sans', sans-serif;
    background-color: white;
    /*position: absolute;*/
    top: 20px;
    margin-bottom: auto;
    padding-bottom: 20px;
    right: 20px;
    left: 20px;
    align-self: center;
}

h3 {
    font-weight: 300;
}

p {
    font-weight: 300;
}

body {
    background-color: lightgray;
}
Run Code Online (Sandbox Code Playgroud)

任何帮助,甚至拉请求将不胜感激。谢谢。

html css margin

0
推荐指数
1
解决办法
363
查看次数

标签 统计

python ×3

cgi ×1

css ×1

html ×1

http ×1

margin ×1

methods ×1

phone-number ×1

post ×1

string-formatting ×1

syntax ×1