我正在尝试使用pickle从二进制文件中读取,调整其内容,然后使用新更新的字典覆盖二进制文件的内容。 但是,我收到此错误:
startHandCountFile = open(" startHandCount",' wb')OSError:[Errno 22] 参数无效:' startHandCount'。
我目前的理解是它应该工作,因为文件与正在运行的python文件位于同一目录中,我已经检查过我没有错过拼写文件。
我的代码:
<div class="wpt_test fill_form">
<div class="answers">
<div class="content">
<form
<?php foreach ($formAttributes as $key => $value):?>
<?php echo $key ?>="<?php echo htmlspecialchars(is_array($value) ? json_encode($value) : $value) ?>"
<?php endforeach; ?>>
<?php if ($isShowContent): ?><div class="content" style="margin:0;"><?php echo $content ?></div><?php endif ?>
<?php if ($shortDescription): ?><div class="short-description"><?php echo $wp->autoParagraphise($shortDescription) ?></div><?php endif ?>
<?php $wp->doAction('wp_testing_template_fill_form_questions_before') ?>
<?php foreach($questions as $q => $question): /* @var $question WpTesting_Model_Question */ ?>
<?php $wp->doAction('wp_testing_template_fill_form_question_before', $question, $q) ?>
<div class="question">
<div class="title">
<span class="question-title" style="width:100%;"><?php echo $question->getTitle() ?>
<?php $wp->doAction('wp_testing_template_fill_form_label_end', array('required' => true)) ?></span>
<?php if (!$isMultipleAnswers): ?>
<input type="hidden" name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="" />
<?php endif ?>
</div>
<div class="answer-block">
<?php foreach($question->buildAnswers() as $a => $answer): /* @var $answer WpTesting_Model_Answer */ ?>
<?php $answerId = 'wpt-test-question-' . $question->getId() . '-answer-' . $answer->getId() ?>
<div class="question-titles">
<div class="question-labels">
<label for="<?php echo $answerId ?>">
<input type="<?php echo $isMultipleAnswers ? 'checkbox' : 'radio' ?>" id="<?php echo $answerId ?>"
data-errormessage="<?php echo $isMultipleAnswers
? __('Please select at least one answer.', 'wp-testing')
: __('Please choose only one answer.', 'wp-testing') ?>"
<?php if (0 == $a): ?>required="required" aria-required="true"<?php endif ?>
name="<?php echo $answerIdName ?>[<?php echo $answerIndex ?>]" value="<?php echo $answer->getId() ?>" />
<?php echo $answer->getTitleOnce() ?>
</label>
</div>
</div>
<?php if ($isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
</div>
<?php $wp->doAction('wp_testing_template_fill_form_question_after', $question, $q) ?>
<?php if (!$isMultipleAnswers) {$answerIndex++;} ?>
<?php endforeach ?>
</div>
<?php $wp->doAction('wp_testing_template_fill_form_questions_after') ?>
<?php if($isFinal): ?>
<p>
<input type="submit" class="button" value="<?php echo $submitButtonCaption ?>" />
<?php if($stepsCounter): ?><span class="steps-counter"><?php echo $stepsCounter ?></span><?php endif ?>
</p>
<?php else: ?>
<div class="wpt_warning">
<h4><?php echo __('Test is under construction', 'wp-testing') ?></h4>
<p><?php echo __('You can not get any results from it yet.', 'wp-testing') ?></p>
</div>
<?php endif ?>
<?php foreach($hiddens as $name => $value): ?><input type="hidden" name="<?php echo htmlspecialchars($name) ?>" value="<?php echo htmlspecialchars($value) ?>" /><?php endforeach ?>
</form>
</div>
</div>
</div>
感谢您的帮助。
答案 0 :(得分:0)
尝试在我的Dropbox之外和我硬盘上的目录中运行我的程序,这解决了我遇到的错误。