我很新,所以只是学习,所以请放轻松!
start = int(input('How much did you start with?:' ))
if start < 0:
print("That's impossible! Try again.")
print(start = int(input('How much did you start with:' )))
if start >= 0:
print(inorout = raw_input('Cool! Now have you put money in or taken it out?: '))
if inorout == in:
print(in = int(raw_input('Well done! How much did you put in?:')))
print(int(start + in))
Run Code Online (Sandbox Code Playgroud)
这总是会导致语法错误?我确定我做的事情明显不对!
谢谢!
我继续使用以下语法获得无效语法:
if (row[0] == year) and (row[1] == month) and (row[2] == day and (row[3] == hour) and (row[4] == minute):
print "hello"
else:
print "hello2"
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
请原谅标题中含糊不清的内容 - 我不太清楚如何表达我的问题.
给定一个字符串:
blah = "There are three cats in the hat"
Run Code Online (Sandbox Code Playgroud)
和(我不太确定使用哪个数据结构)"userInfo":
cats -> ("tim", "1 infinite loop")
three -> ("sally", "123 fake st")
three -> ("tim", "1 infinite loop")
three cats -> ("john", "123 fake st")
four cats -> ("albert", "345 real road")
dogs -> ("tim", "1 infinite loop")
cats hat -> ("janet", NULL)
Run Code Online (Sandbox Code Playgroud)
适当的输出应该是:
tim (since 'cats' exists)
sally (since 'three' exists)
tim (since 'three' exists)
john (since both 'three' and 'cats' exist)
janet (since both …
Run Code Online (Sandbox Code Playgroud) 我正在网站中搜索一个字符串,并检查该字符串的位置是否在预期的位置.我知道字符串从第182个字符开始,如果我打印temp,它甚至会告诉我它是182,但if语句说182不是182.
f = urllib.urlopen(link)
#store page contents in 's'
s = f.read()
f.close()
temp = s.find('lettersandnumbers')
if (htmlsize == "197"):
#if ((s.find('lettersandnumbers')) == "182"):
if (temp=="182"):
print "Glorious"
doStuff()
else:
print "HTML not correct. Aborting."
else:
print htmlsize
print "File size is incorrect. Aborting."
Run Code Online (Sandbox Code Playgroud) <div id="left-body-part-innerpage">
<h1 class="mainheading">Contact Us</h1>
<div id="contactus-right-div" class="content">
<?php session_start();
if( isset($_POST['button2']))
{
if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) )
{
$name = $_POST['name'];
// Insert you code for processing the form here, e.g emailing the submission, entering it into a database.
session_destroy();
header("Location: contactdb.php");
?>
Run Code Online (Sandbox Code Playgroud)
我收到警告:session_start()[function.session-start]:无法发送会话缓存限制器 - 网站已经发送(网站开始输出)
警告:无法修改标题信息 - 已在网站上发送(在网站上开始输出)的标题
谁能帮我?
提前致谢....
如果:
x = 0
b = x==0
Run Code Online (Sandbox Code Playgroud)
我打印它会打印'真'
但如果我做了:
x = 0
b = x == 3
我印的是假的.而不是它打印假如何我将采用布尔值'b'来打印我想要的文本?
让我进一步解释一下:
bool = all(n > 0 for n in list)
if bool != 'True':
print 'a value is not greater than zero'
Run Code Online (Sandbox Code Playgroud)
但它什么都不打印?
def a():
w='www'
a.a='aaa'
print a.__dict__
a.__dict__={'1':'111','2':'222'}
print a.1#error
print a['1']#error
Run Code Online (Sandbox Code Playgroud)
我怎么能得到'111'的价值谢谢
任何人都可以告诉我这段代码有什么问题:
#!/usr/local/bin/python
import os
import string, sys
a='sys.argv[1]'
b='sys.argv[2]'
os.system("scp a:/export/home/sample/backup.sql b:/home/rushi/abc.sql")
Run Code Online (Sandbox Code Playgroud)
它给出了以下错误:
ssh: a: node name or service name not known
Run Code Online (Sandbox Code Playgroud) 我想要在Python中完成以下任务而不导入任何模块.
我的守则包括
Two List
---------
list1=['aun','2ab','acd','3aa']
list2=['ca3','ba2','dca','aa3']
Function
---------
Run Code Online (Sandbox Code Playgroud)
它会在哪里:
我不需要打印这两个项目的所有组合
但是我希望将所有这两个项目组合传递给进一步的任务并显示结果
analysize R.. **ca3** .... and ... **2ab** // Combinations of two items from list1 and list2
Print analysize
Run Code Online (Sandbox Code Playgroud) 我们刚刚开始在我的CSCI课程中使用字符串,但我对最近的任务感到困惑.
给你一个长字符串:
"""Justin$Calculus$90$Java$85$Python88$
Taylor$Calculus$73$Java$95$Python86$
Drew$Calculus$80$Java$75$Python94$
"""
Run Code Online (Sandbox Code Playgroud)
该字符串有三行.它包含三个学生的三门课程的分数.写一个函数
findScore(student, subject)
.当您调用此功能时findScore(‘Drew’,’Java’)
,该功能会打印出来“Drew got 75 of the course Java.”
除了该功能
findScore(student, subject)
,您还可以编写其他功能.所有功能都在一个程序中.
我假设我需要将此字符串分配给变量,但是我是使用一个变量,还是每行一个变量?
任何开始的想法将不胜感激.我是python的新手所以请耐心等待.此外,$
标志的意义是什么?
我尝试运行脚本时收到错误
Error:"IndentationError: unindent does not match any outer indentation"
Run Code Online (Sandbox Code Playgroud)
抛出错误的代码snipet:
def update():
try:
lines = open("vbvuln.txt", "r").readlines()
except(IOError):
print "[-] Error: Check your phpvuln.txt path and permissions"
print "[-] Update Failed\n"
sys.exit(1)
try:
Run Code Online (Sandbox Code Playgroud)
这是出现错误的实际行:
print "[-] Update Failed\n"
Run Code Online (Sandbox Code Playgroud) python ×11
syntax ×2
boolean ×1
combinations ×1
header ×1
indentation ×1
php ×1
session ×1
string ×1
syntax-error ×1