继承人我做了什么..
>>> soup = BeautifulSoup (html)
>>> soup
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xae' in position 96953: ordinal not in range(128)
>>>
>>> soup.find('div')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xae' in position 11035: ordinal not in range(128)
>>>
>>> soup.find('span')
<span id="navLogoPrimary" class="navSprite"><span>amazon.com</span></span>
>>>
Run Code Online (Sandbox Code Playgroud)
如何从中删除令人不安的unicode字符html?
或者有更清洁的解决方案吗?
我已经获得了一个称为静态Java编译器的Java编译器子集的ANTLR语法.我正在尝试扩展语法以包含更多Java的功能,例如,我刚刚为For Loops添加了语法.
使用Eclipse和ANTLR插件,然后我做了"编译ANTLR语法".而不是编译它在第一个代码位上产生了两个错误:
grammar ExtendedStaticJava;
options { backtrack=true; memoize=true; }
@header
{
package sjc.parser.extended;
import java.math.BigInteger;
/**
* Extended StaticJava parser.
* @author <myname>
*/
}
// the rest of the grammar has been excluded.
Run Code Online (Sandbox Code Playgroud)
第一个错误在第1行:'Unexpected Token:grammar'第二个错误在第5行:'意外的char:@'
为什么它不能识别这种基本的ANTLR语法?我的第一个想法是我在类路径中遗漏了一些东西,但是我去了项目的属性,并确保在库下包含以下JAR :
任何想法或建议?
我有一个基类,它有一个方法将文件移动到适当的文件夹.有许多不同的文件有许多不同的命名方案.每个文件的移动和文件夹创建都是相同的,但由于文件名不同,确定日期也不同.我想这样做:
public class FileBase
{
protected FileInfo _source;
protected string GetMonth()
{
// 2/3 Files have the Month in this location
// So I want this to be used unless a derived class
// redefines this method.
return _source.Name.Substring(Source.Name.Length - 15, 2);
}
public void MoveFileToProcessedFolder()
{
MoveFileToFolder(Properties.Settings.Default.processedFolder + GetMonth);
}
private void MoveFileToFolder(string destination)
{
....
}
}
public class FooFile : FileBase
{
protected new string GetMonth()
{
return _source.Name.Substring(Source.Name.Length - 9, 2);
}
}
public class Program …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 bash 脚本调用 Ruby 脚本,但没有运气。
#!/bin/bash
ruby -v
Run Code Online (Sandbox Code Playgroud)
工作得很好,所以我知道它不是 Ruby,但是
#!/bin/bash
ruby bash_test.rb
Run Code Online (Sandbox Code Playgroud)
才不是。这是有趣的部分:
john@starfire:~/Desktop$ bash ubuntu_cmds.sh
(LoadError)h file or directory -- bash_test.rb
john@starfire:~/Desktop$ ls *.rb
bash_test.rb
Run Code Online (Sandbox Code Playgroud)
这两个文件都在我的桌面上。
ruby bash_test.rb
Run Code Online (Sandbox Code Playgroud)
也很好用。
我是 bash 脚本的新手,所以我很确定我只是犯了一个愚蠢的错误。
我正在使用 Ruby 1.8.7 运行 Ubuntu 10.10。在此先感谢您的任何帮助或建议。
编辑:删除 .sh 和 .rb 并重新开始,并确保chmod +x.sh,并且它在第一次尝试时起作用。我不知道为什么。不过还是谢谢你的帮助。
我最近开始使用Threads,我正在尝试在Android中完成Looper类的Java实现.基本上我正在创建一个Java类,它将线程放入一个队列,然后由Looper类执行.我已经完成了大部分代码但是在排队任务时遇到了问题.
在Looper类中,我声明了队列和我的入队方法:
List<Runnable> queue;
public synchronized void enqueue(Runnable runnable) {
queue.add(runnable);
notify(); // signal a waiting thread
}
Run Code Online (Sandbox Code Playgroud)
然后我创建了另一个名为TaskManager的类来将Tasks添加到队列中.我打电话时收到错误:
loop.enqueue(new Task());
Run Code Online (Sandbox Code Playgroud)
其中Task()实现了runnable,只是在run()方法中将两个整数相加......这只是一个测试.
我收到的错误是:
Exception in thread "Thread-0" java.lang.NullPointerException
at Looper.enqueue(Looper.java:20) (this is the queue.add(runnable))
at TaskMaker.run(TaskMaker.java:16) (this is the loop.enqueue(new Task())
Run Code Online (Sandbox Code Playgroud)
我显然做错了什么并没有实现这个......我该怎么做呢?我排队的任务是正确的吗?感谢您的帮助,非常感谢!
我正在攻读考试,这是旧考试的一个问题:
我们有一个带有列表头的单链表,其中包含以下声明:
class Node {
Object data;
Node next;
Node(Object d,Node n) {
data = d;
next = n;
}
}
Run Code Online (Sandbox Code Playgroud)
编写一个在列表末尾void addLast(Node header, Object x)添加的方法x.
我知道,如果我真的有这样的东西:
LinkedList someList = new LinkedList();
Run Code Online (Sandbox Code Playgroud)
我可以通过以下方式添加项目到最后:
list.addLast(x);
Run Code Online (Sandbox Code Playgroud)
但是我怎么能在这里做呢?
当我编写下面的代码时,为什么我得到可用的线程编号,如1022,1020.我必须得到25个线程最大,因为我使用线程池.
我猜输出线程号是系统上的可用线程.我需要在win表单应用程序中的线程池中获取可用的线程号.
private void Foo()
{
int intAvailableThreads, intAvailableIoAsynThreds;
// ask the number of avaialbe threads on the pool,
//we really only care about the first parameter.
ThreadPool.GetAvailableThreads(out intAvailableThreads,
out intAvailableIoAsynThreds);
// build a message to log
string strMessage =
String.Format(@"Is Thread Pool: {1},
Thread Id: {2} Free Threads {3}",
Thread.CurrentThread.IsThreadPoolThread.ToString(),
Thread.CurrentThread.GetHashCode(),
intAvailableThreads);
// check if the thread is on the thread pool.
Trace.WriteLine(strMessage);
// create a delay...
Thread.Sleep(30000);
return;
}
Run Code Online (Sandbox Code Playgroud)
非常感谢..
(注意:我从http://www.codeproject.com/KB/cs/AsyncMethodInvocation.aspx获得了代码)很好的文章!!
我正在测试我的应用程序而且我一直在接收这些泄漏,但它们都没有在我的代码中.我想,还有其他人有这些问题吗?
__NSCFDictionary 0x5f8cfe0 48 AudioToolbox SimAggregateDevice::SimAggregateDevice(__CFString const*, __CFString const*, long&)
Malloc 32 Bytes 0x5f83a00 32 AudioToolbox SimAggregateDevice::SimAggregateDevice(__CFString const*, __CFString const*, long&)
Malloc 48 Bytes 0x5f839d0 48 AudioToolbox SimAggregateDevice::SimAggregateDevice(__CFString const*, __CFString const*, long&)
Malloc 32 Bytes 0x5f839b0 32 AudioToolbox CreateDictionaryForDevice(unsigned long)
Malloc 32 Bytes 0x5f83990 32 AudioToolbox CreateDictionaryForDevice(unsigned long)
__NSCFDictionary 0x5f83960 48 AudioToolbox CreateDictionaryForDevice(unsigned long)
Malloc 32 Bytes 0x5f83940 32 AudioToolbox SimAggregateDevice::SimAggregateDevice(__CFString const*, __CFString const*, long&)
__NSCFArray 0x5f838b0 32 AudioToolbox SimAggregateDevice::SimAggregateDevice(__CFString const*, __CFString const*, long&)
Run Code Online (Sandbox Code Playgroud)
任何帮助都会很棒,谢谢......是的...一个新手.
我在上一个关于S O的问题中找到了以下代码.在下面的代码中,如果用户提供的用户名和密码正确,则user_id和username存储在会话中以保持记录.我的问题是,为什么需要在会话中保留user_id?是不是只有一件事(例如,用户名)足以存储在会话中?如果启用了记住,则仅设置用户名的cookie.现在我的问题是,只有用户名cookie足够吗?任何人都不能只在浏览器中编辑或添加cookie并登录系统吗?
谢谢你的回复.
<?
public function login($username, $pass, $remember) {
// check username and password with db
$result = $conn->query("select * from login where
username='".$username."' and
password=sha1('".$pass."')");
if (!$result) {
throw new depException('Incorrect username and password combination. Please try again.');
}
if ($result->num_rows>0) {
$row = $result->fetch_assoc();
$_SESSION['user_id'] = $row[user_id];
$_SESSION['username'] = $username;
// start rememberMe
$cookie_name = 'db_auth';
$cookie_time = (3600 * 24 * 30);*/ // 30 days
// check to see …Run Code Online (Sandbox Code Playgroud) java ×3
c# ×2
antlr ×1
antlrworks ×1
bash ×1
debugging ×1
eclipse ×1
html-parsing ×1
instruments ×1
ios ×1
iphone ×1
javascript ×1
linked-list ×1
linux ×1
memory-leaks ×1
node.js ×1
parsing ×1
php ×1
python ×1
queue ×1
ruby ×1
runnable ×1
scripting ×1
threadpool ×1
unicode ×1