我正在使用urllib从网站获取一串html,并需要将html文档中的每个单词放入一个列表中.
这是我到目前为止的代码.我一直在收到错误.我也复制了下面的错误.
import urllib.request
url = input("Please enter a URL: ")
z=urllib.request.urlopen(url)
z=str(z.read())
removeSpecialChars = str.replace("!@#$%^&*()[]{};:,./<>?\|`~-=_+", " ")
words = removeSpecialChars.split()
print ("Words list: ", words[0:20])
Run Code Online (Sandbox Code Playgroud)
这是错误.
Please enter a URL: http://simleyfootball.com
Traceback (most recent call last):
File "C:\Users\jeremy.KLUG\My Documents\LiClipse Workspace\Python Project 2\Module2.py", line 7, in <module>
removeSpecialChars = str.replace("!@#$%^&*()[]{};:,./<>?\|`~-=_+", " ")
TypeError: replace() takes at least 2 arguments (1 given)
Run Code Online (Sandbox Code Playgroud) 我正在尝试学习PHP,并且我一直在遇到PHP错误.这是http://projects.jeremyohmann.com/homework网站的链接.有人可以查看我的代码,看看我做错了什么吗?我认为错误在head.php中的某处,但也可能在Login.php中.用户在页面刷新后不断注销,因此我假设它与php会话有关.
我得到的确切错误是:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/jeremyohmann/www/projects/homework/head.php:2) in /home/jeremyohmann/www/projects/homework/classes/Login.php on line 30
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/jeremyohmann/www/projects/homework/head.php:2) in /home/jeremyohmann/www/projects/homework/classes/Login.php on line 30
Run Code Online (Sandbox Code Playgroud)
head.php
<html>
<?php
require_once ('config/config.php');
require_once ('config/db.php');
require_once ('classes/Login.php');
$login = new Login(); ?>
<head>
<title>Homework Managment Project</title>
<link rel="stylesheet" type="text/css" href="reset.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<div id="wrapper">
<div id="header"><h1>Homework Management Project</h1></div>
<div …Run Code Online (Sandbox Code Playgroud) 我试图将一个单词列表读入一个数组.我在这个网站上已经阅读了一些教程和其他问题,但仍然被卡住了.这可能是我想念的简单但我无法理解的.
这是我的代码:
string badWordsFilePath = openFileDialog2.FileName.ToString();
badWords = badWordsFilePath.Split(' ');
MessageBox.Show("Words have been imported!");
BadWordsImported = true;
Run Code Online (Sandbox Code Playgroud)
我想要发生的是将文件中的所有单词逐个放入数组badWords中.
我有什么想法我做错了吗?