我需要能够从用户获取电子邮件地址,然后使用PHP向他们发送带有链接的电子邮件.我知道有一些使用jquery或AJAX的实现,但我没有任何这些主题的经验.我希望有一些简单的事情.谢谢
例如:
What is your name?
Anna
Hello Anna
Run Code Online (Sandbox Code Playgroud)
我已经尝试了一些东西;
print
var = (input("What is your name? ")
print:("you entered", var)
Run Code Online (Sandbox Code Playgroud)
但我收到的只是语法无效.
我正在运行Python 2.7.10.我正在处理的程序中有以下代码块.
with open('inventory.txt', 'r+') as f:
inventory = {}
while True:
item = raw_input('Item: ')
inventory[item] = raw_input('Price: ')
if item == '':
del inventory['']
break
inv = str(inventory)
f.write(inv).rstrip()
print inventory
print inv
print f.read()
Run Code Online (Sandbox Code Playgroud)
它的作用是提示用户输入项目和价格,然后将所有这些存储为键/值对,然后将该最终字典写入第二个文本文件.然而,在第5行,它似乎是唯一的输入类型,除了有一个字符串.我试图用float()包围raw_input,并尝试使额外的变量无济于事.我能够将raw_input包装在一个int()中,它可以工作,所以它把我扔了.
当我将第5行更改为库存[item] = float(raw_input('Price:'))时,我收到以下错误:
File "C:\Users\Jarrall\Desktop\store\script.py", line 5, in <module>
inventory[item] = float(raw_input('Price: '))
ValueError: could not convert string to float:
Run Code Online (Sandbox Code Playgroud)
我必须对代码进行哪些更改,以便当用户在第5行输入数值时,它会保存到字典而不是字符串(当前)?
我知道通过使用Convert.To方法读取输入,但除此之外还有什么方法可以阅读.
int k = Convert.ToInt16(Console.ReadLine());
Run Code Online (Sandbox Code Playgroud) 我是python编码的新手,需要知道如何只允许用户在输入名称时输入字母.因此,如果他们输入一个数字或根本不输入任何数字,我希望代码说"请仅使用字母,再试一次".
干杯克里斯
是否可以将页面上的元素从输入文本字段更改为使用 JavaScript 选择选项元素?
我想用greasemonkey.
我正在寻找一种干净的方法来分割Scala中的字符串中的换行符,无论换行符是CR和/或LF.我一直在使用.split一个基本的正则表达式,但它看起来很难看,因为标准库自然会为系统无关的代码封装 - 有没有标准的库函数呢?
提前致谢!
编辑:
我喜欢我的代码与系统无关,因为它是JVM的一大卖点.让我的代码知道硬编码字符串中的不同操作系统约定 - 文字正则表达式似乎(非常轻微地)打破了这一点.似乎应该由功能丰富的Scala标准库自然地抽象出来,我只是想知道是否存在内置方法.
我正在用 Python 开发一个新项目,它的作用是从用户那里获取 3 个输入,然后最后将所有输入显示为 1 个句子。我面临的问题是我想将一些选项作为输入。我已经将所有选项作为普通文本打印为选项 1、2、3、4。那么,如果输入是 1,2,3,4,有什么方法可以改变输入吗?任何有关在 Python 中使用选项作为输入的帮助将不胜感激
我有以下代码在py 27和36中都有效:
all_config_msgs = ['Okta App URL. E.g https://acme.okta.com/home/amazon_aws/b07384d113edec49eaa6/123: ','Organization username. E.g jane.doe@acme.com: ']
config_details = []
for config_msg in all_config_msgs:
config_details.append(input(config_msg))
Run Code Online (Sandbox Code Playgroud)
在py 36和27中,我得到输入提示:
Okta App URL.例如https://acme.okta.com/home/amazon_aws/b07384d113edec49eaa6/123:
any_reply
它成功了
any_reply
失败了
config_details.append(input(config_msg))
File "<string>", line 1
https://acme.okta.com/home/amazon_aws/b07384d113edec49eaa6/123
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)
仅供参考 - 在py 27中,如果我将响应设置为"any_reply",它就可以工作 但我需要有一种方法来回答没有双引号/引号.
我在py 27中理解,输入正在进行eval但是将输入提示作为变量而不会出现上述错误的好方法.
这是我的代码
using System;
namespace Test
{
class Main
{
public static void MainVoid(string[] args)
{
Console.WriteLine("Enter x: ");
string x = Console.ReadLine();
Console.Write(x + "!");
}
}
}
Run Code Online (Sandbox Code Playgroud)
编译器抛出错误
在名称空间“ Rextester”的“程序”类中找不到输入方法“ Main”
input ×10
python ×5
c# ×2
javascript ×2
python-2.7 ×2
string ×2
beginread ×1
element ×1
email ×1
html ×1
inputstream ×1
io ×1
line-breaks ×1
options ×1
php ×1
python-3.x ×1
scala ×1
select ×1
sendmail ×1
split ×1
variables ×1